<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>增加缴费信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid" style="width: 600px;margin-top: 30px;">
    <div class="layui-row">
        <div class="layui-form">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>业主名字
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="username" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
<!--
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>缴费编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="pnumber" name="phone" required="" lay-verify="phone"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
-->
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>缴费金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="pmoney"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                <span class="x-red">*</span>支付类型
            </label>
            <div class="layui-input-inline layui-show-xs-block">
                <select name="contrller" id="pway">
                    <option value="0">支付类型</option>
                    <option value="1">支付宝</option>
                    <option value="2">微信</option>
                </select>
            </div>
            </div>

            <label for="phone" class="layui-form-label">
                <span class="x-red">*</span>缴费类型
            </label>
            <div class="layui-input-inline layui-show-xs-block">
                <select name="contrller" id="type">
                    <option value="0">缴费类型</option>
                    <option value="1">水费</option>
                    <option value="2">电费</option>
                    <option value="3">物业费</option>
                    <option value="4">保洁费</option>
                    <option value="5">天然气费</option>
                    <option value="6">取暖器费</option></select>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" id="butt" lay-filter="add" lay-submit="">
                    增加
                </button>
                <button style="margin-left: 90px;"  class="layui-btn" lay-filter="add" lay-submit="">
                    清空
                </button>
            </div>
        </div>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
    });</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>
</html>
<script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
<script>
    $("#butt").click(function () {
        let name = $("#name").val();
       /* let pnumber = $("#pnumber").val();*/
        let pmoney = $("#pmoney").val();
        let pway = $("#pway option:selected").text();
        let type = $("#type option:selected").val();//单元
        let flag = true;
        if (name == "" || pmoney == "" ||  pway == "请选择" ||type=="0" ) {
            layer.msg('缴费信息填写完整!', {
                icon: 2, time: 800
            });
            flag = false;
        }
        if (flag) {
            layui.use(['table', 'jquery'], function () {
                var table = layui.table;
                var $ = layui.jquery;
                $.ajax({
                    type: "POST",
                    url: "http://localhost:8080/api/xzpay",
                    data: {
                        "name": name,
                        "pMoney": pmoney,
                        "ptId": type,
                        "pWay": pway,
                    },
                    headers: {
                        token: localStorage.getItem("token")
                    },
                    datatype: "json",
                    success: function (data) {
                        if (data.name==0){
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg('本社区没有此业主!',{
                                icon:2
                                ,time:800
                            });
                        }
                        if (data.data>0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            layer.msg('缴费记录增加成功!',{
                                icon:1
                                ,time:800
                            },function (){
                                parent.layer.close(index);//关闭当前页
                            });
                        }
                    }
                })
            })
        }
    })

</script>
